# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -simplify-mir -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff \
# RUN:   -stop-after=postrapseudos %s -o - | FileCheck %s

---
name: foo
alignment: 8
tracksRegLiveness: true
body: |
  bb.0.entry:
  liveins: $x3, $x4
    ; CHECK-LABEL: name: foo
    ; CHECK: liveins: $x3, $x4
    ; CHECK: early-clobber renamable $g8p3 = LQ 128, $x4
    ; CHECK: $x3 = OR8 $x7, $x7
    ; CHECK: STQ killed renamable $g8p3, 160, $x3
    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
  %0:g8prc = LQ 128, $x4
  $x3 = COPY %0.sub_gp8_x1:g8prc
  STQ %0, 160, $x3
  BLR8 implicit $lr8, implicit undef $rm, implicit $x3
...

---
name: foobar
alignment: 8
tracksRegLiveness: true
body: |
  bb.0.entry:
  liveins: $x3, $x4
    ; CHECK-LABEL: name: foobar
    ; CHECK: liveins: $x3, $x4
    ; CHECK: renamable $g8p3 = LQARX $x3, $x4
    ; CHECK: STQCX renamable $g8p3, $x3, $x4, implicit-def dead $cr0
    ; CHECK: $x3 = OR8 $x7, killed $x7
    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
  %0:g8prc = LQARX $x3, $x4
  STQCX %0:g8prc, $x3, $x4, implicit-def $cr0
  $x3 = COPY %0.sub_gp8_x1:g8prc
  BLR8 implicit $lr8, implicit undef $rm, implicit $x3
...

---
name: bar
alignment: 8
tracksRegLiveness: true
body: |
  bb.0.entry:
  liveins: $x3, $x4
    ; CHECK-LABEL: name: bar
    ; CHECK: liveins: $x3, $x4
    ; CHECK: early-clobber renamable $g8p2 = LQ 128, renamable $x3
    ; CHECK: STQ renamable $g8p2, 160, $x3
    ; CHECK: $x3 = OR8 $x4, killed $x4
    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
  %0:g8rc_nox0 = COPY $x3
  %1:g8prc = LQ 128, %0
  STQ %1, 160, $x3
  $x3 = COPY %1.sub_gp8_x0:g8prc
  BLR8 implicit $lr8, implicit undef $rm, implicit $x3
...

# `spill_g8prc`'s code contains undefined behaviors. This code is only to
# demonstrate correctness of spiller.
---
name: spill_g8prc
alignment: 8
tracksRegLiveness: true
body: |
  bb.0.entry:
  liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12
    ; CHECK-LABEL: name: spill_g8prc
    ; CHECK: liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28, $x29, $x30, $x31
    ; CHECK: STD killed $x14, -144, $x1 :: (store (s64) into %fixed-stack.17, align 16)
    ; CHECK: STD killed $x15, -136, $x1 :: (store (s64) into %fixed-stack.16)
    ; CHECK: STD killed $x16, -128, $x1 :: (store (s64) into %fixed-stack.15, align 16)
    ; CHECK: STD killed $x17, -120, $x1 :: (store (s64) into %fixed-stack.14)
    ; CHECK: STD killed $x18, -112, $x1 :: (store (s64) into %fixed-stack.13, align 16)
    ; CHECK: STD killed $x19, -104, $x1 :: (store (s64) into %fixed-stack.12)
    ; CHECK: STD killed $x20, -96, $x1 :: (store (s64) into %fixed-stack.11, align 16)
    ; CHECK: STD killed $x21, -88, $x1 :: (store (s64) into %fixed-stack.10)
    ; CHECK: STD killed $x22, -80, $x1 :: (store (s64) into %fixed-stack.9, align 16)
    ; CHECK: STD killed $x23, -72, $x1 :: (store (s64) into %fixed-stack.8)
    ; CHECK: STD killed $x24, -64, $x1 :: (store (s64) into %fixed-stack.7, align 16)
    ; CHECK: STD killed $x25, -56, $x1 :: (store (s64) into %fixed-stack.6)
    ; CHECK: STD killed $x26, -48, $x1 :: (store (s64) into %fixed-stack.5, align 16)
    ; CHECK: STD killed $x27, -40, $x1 :: (store (s64) into %fixed-stack.4)
    ; CHECK: STD killed $x28, -32, $x1 :: (store (s64) into %fixed-stack.3, align 16)
    ; CHECK: STD killed $x29, -24, $x1 :: (store (s64) into %fixed-stack.2)
    ; CHECK: STD killed $x30, -16, $x1 :: (store (s64) into %fixed-stack.1, align 16)
    ; CHECK: STD killed $x31, -8, $x1 :: (store (s64) into %fixed-stack.0)
    ; CHECK: $x7 = OR8 $x3, $x3
    ; CHECK: renamable $g8p4 = LQARX $x5, $x6
    ; CHECK: STD killed $x8, -160, $x1
    ; CHECK: STD killed $x9, -152, $x1
    ; CHECK: renamable $g8p5 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p4 = LQARX $x3, renamable $x4
    ; CHECK: STD killed $x8, -176, $x1
    ; CHECK: STD killed $x9, -168, $x1
    ; CHECK: renamable $g8p4 = LQARX $x3, renamable $x4
    ; CHECK: STD killed $x8, -192, $x1
    ; CHECK: STD killed $x9, -184, $x1
    ; CHECK: renamable $g8p4 = LQARX $x3, renamable $x4
    ; CHECK: STD killed $x8, -208, $x1
    ; CHECK: STD killed $x9, -200, $x1
    ; CHECK: renamable $g8p4 = LQARX $x3, renamable $x4
    ; CHECK: STD killed $x8, -224, $x1
    ; CHECK: STD killed $x9, -216, $x1
    ; CHECK: renamable $g8p10 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p9 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p8 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p7 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p15 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p11 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p12 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p13 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p14 = LQARX $x3, renamable $x4
    ; CHECK: renamable $g8p4 = LQARX $x3, renamable $x4
    ; CHECK: $x3 = OR8 $x11, $x11
    ; CHECK: STQCX killed renamable $g8p4, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p14, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p13, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p12, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p11, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p15, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p7, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p8, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p9, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p10, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: $x8 = LD -224, $x1
    ; CHECK: $x9 = LD -216, $x1
    ; CHECK: STQCX killed renamable $g8p4, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: $x8 = LD -208, $x1
    ; CHECK: $x9 = LD -200, $x1
    ; CHECK: STQCX killed renamable $g8p4, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: $x8 = LD -192, $x1
    ; CHECK: $x9 = LD -184, $x1
    ; CHECK: STQCX killed renamable $g8p4, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: $x8 = LD -176, $x1
    ; CHECK: $x9 = LD -168, $x1
    ; CHECK: STQCX killed renamable $g8p4, renamable $x7, renamable $x4, implicit-def dead $cr0
    ; CHECK: STQCX killed renamable $g8p5, killed renamable $x7, killed renamable $x4, implicit-def dead $cr0
    ; CHECK: $x8 = LD -160, $x1
    ; CHECK: $x9 = LD -152, $x1
    ; CHECK: STQCX killed renamable $g8p4, $x5, $x6, implicit-def dead $cr0
    ; CHECK: $x31 = LD -8, $x1 :: (load (s64) from %fixed-stack.0)
    ; CHECK: $x30 = LD -16, $x1 :: (load (s64) from %fixed-stack.1, align 16)
    ; CHECK: $x29 = LD -24, $x1 :: (load (s64) from %fixed-stack.2)
    ; CHECK: $x28 = LD -32, $x1 :: (load (s64) from %fixed-stack.3, align 16)
    ; CHECK: $x27 = LD -40, $x1 :: (load (s64) from %fixed-stack.4)
    ; CHECK: $x26 = LD -48, $x1 :: (load (s64) from %fixed-stack.5, align 16)
    ; CHECK: $x25 = LD -56, $x1 :: (load (s64) from %fixed-stack.6)
    ; CHECK: $x24 = LD -64, $x1 :: (load (s64) from %fixed-stack.7, align 16)
    ; CHECK: $x23 = LD -72, $x1 :: (load (s64) from %fixed-stack.8)
    ; CHECK: $x22 = LD -80, $x1 :: (load (s64) from %fixed-stack.9, align 16)
    ; CHECK: $x21 = LD -88, $x1 :: (load (s64) from %fixed-stack.10)
    ; CHECK: $x20 = LD -96, $x1 :: (load (s64) from %fixed-stack.11, align 16)
    ; CHECK: $x19 = LD -104, $x1 :: (load (s64) from %fixed-stack.12)
    ; CHECK: $x18 = LD -112, $x1 :: (load (s64) from %fixed-stack.13, align 16)
    ; CHECK: $x17 = LD -120, $x1 :: (load (s64) from %fixed-stack.14)
    ; CHECK: $x16 = LD -128, $x1 :: (load (s64) from %fixed-stack.15, align 16)
    ; CHECK: $x15 = LD -136, $x1 :: (load (s64) from %fixed-stack.16)
    ; CHECK: $x14 = LD -144, $x1 :: (load (s64) from %fixed-stack.17, align 16)
    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit $x3
  %addr0:g8rc_nox0 = COPY $x3
  %addr1:g8rc = COPY $x4
  %0:g8prc = LQARX $x5, $x6
  %1:g8prc = LQARX %addr0, %addr1
  %2:g8prc = LQARX %addr0, %addr1
  %3:g8prc = LQARX %addr0, %addr1
  %4:g8prc = LQARX %addr0, %addr1
  %5:g8prc = LQARX %addr0, %addr1
  %6:g8prc = LQARX %addr0, %addr1
  %7:g8prc = LQARX %addr0, %addr1
  %8:g8prc = LQARX %addr0, %addr1
  %9:g8prc = LQARX %addr0, %addr1
  %10:g8prc = LQARX %addr0, %addr1
  %11:g8prc = LQARX %addr0, %addr1
  %12:g8prc = LQARX %addr0, %addr1
  %13:g8prc = LQARX %addr0, %addr1
  %14:g8prc = LQARX %addr0, %addr1
  %15:g8prc = LQARX %addr0, %addr1
  STQCX %15:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %14:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %13:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %12:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %11:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %10:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %9:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %8:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %7:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %6:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %5:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %4:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %3:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %2:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %1:g8prc, %addr0, %addr1, implicit-def $cr0
  STQCX %0:g8prc, $x5, $x6, implicit-def $cr0
  $x3 = COPY %1.sub_gp8_x1:g8prc
  BLR8 implicit $lr8, implicit undef $rm, implicit $x3
...

---
name: copy_g8prc
alignment: 8
tracksRegLiveness: true
body: |
  bb.0.entry:
  liveins: $g8p8
    ; CHECK-LABEL: name: copy_g8prc
    ; CHECK: liveins: $g8p8
    ; CHECK: $x4 = OR8 $x16, $x16
    ; CHECK: $x5 = OR8 $x17, $x17
    ; CHECK: $x3 = OR8 $x5, $x5
    ; CHECK: BLR8 implicit $lr8, implicit undef $rm, implicit killed $x3, implicit $x4
  %0:g8prc = COPY $g8p8
  $x3 = COPY %0.sub_gp8_x1:g8prc
  $x4 = COPY %0.sub_gp8_x0:g8prc
  BLR8 implicit $lr8, implicit undef $rm, implicit $x3, implicit $x4
...
